
'use strict';
const cloud = require('tcb-admin-node');
const tcbConfig = { env: 'meatom04-01-2gue0fnr49a26808' }; //当前环境 ENV_ID
const auth = cloud.init(tcbConfig).auth();
const db = cloud.database();

// 云函数入口函数
exports.main = async (event, context) => {
  let uid = event.uid
  // event
  return db.collection('User').where({
    uid: uid
  })
    .update({
      coin: event.coin,
      diamond: event.diamond,
      bagNum: event.bagNum,
      bag: event.bag,
      team: event.team,
      pass_list: event.pass_list,
      card: event.card,
      card_team: event.card_team,
      guideList: event.guideList,
      task: event.task,
      last_time: (new Date()).valueOf(),
      platform: event.platform,
      sign_histroy:event.sign_histroy
    })
    .then(
      res => {
        return {
          status: true,
          text: '更新成功',
          uid: uid
        }
      }
    ).catch(
      err => {
        return {
          status: false,
          text: '更新失败',
          uid: uid
        }
      }
    )
}
